import React, { useReducer } from 'react';
import { counterReducer } from '../store';

const init = (initState) => initState - 0;

function HookPage() {
  // react 函数式组件中定义状态可以用 useState和useReducer
  const [count, dispatch] = useReducer(counterReducer, '0', init);
  // useReducer 主要用于修改状态的逻辑可以封装共用的场景

  return (
    <div>
      <h3>HookPage</h3>
      <button onClick={() => dispatch({ type: 'ADD', payload: 100 })}>{count}</button>
    </div>
  );
}

export default HookPage;
